package com.xd.lib.tool.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;

/**
 * 窗体辅助类
 * Created by Administrator on 2015/6/12.
 */
public class ActivityUtil {

    /**
     * 获取视图
     * @param context
     * @param layoutId
     * @return
     */
    public static View getView(Context context, int layoutId){
//        LayoutInflater inflater = LayoutInflater.from(context);
        LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        return inflater.inflate(layoutId, null);
    }

    /**
     * 界面跳转并关闭当前的窗口
     * @param context
     * @param dest
     */
    public static void startActivityWithFinish(Context context, Class dest){
        Intent intent = new Intent();
        intent.setClass(context, dest);
        context.startActivity(intent);

        //关闭当前的Activity
        ((Activity)context).finish();
    }
}
